home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / hsrc_117.zip / HEAD2.C < prev    next >
Text File  |  1990-11-09  |  19KB  |  780 lines

  1. /* HeadEdit XBBS message area reader -- Nodelist functions, header
  2.    editor, miscellaneous functions */
  3.  
  4. /* Note this stuff needs to stay together as there is some really sloppy
  5.    sharing of windows and such (bleagh!) */
  6.  
  7. #include "msgg.h"
  8. #include "twindow.h"
  9. #include "keys.h"
  10. #include "headedit.h"
  11.  
  12. extern WINDOW *ewnd;
  13.  
  14.  
  15. static char attrprompts[16][12]={
  16.         "Private:",
  17.         "Crash:",
  18.         "Read:",
  19.         "Sent:",
  20.         "File:",
  21.         "Forward:",
  22.         "Orphan:",
  23.         "Kill:",
  24.         "Local:",
  25.         "XX1:",
  26.         "XX2:",
  27.         "FReq:",
  28.         "RReq:",
  29.         "Receipt:",
  30.         "Audit Rq:",
  31.         "Update Rq:"
  32.     };
  33. static char mattrprompts[][12]={
  34.         "Deleted:",
  35.         "Anonymous:",
  36.         "Echo:",
  37.         "Net:",
  38.         "Hold:",
  39.         "Host Rt:",
  40.         "Scanned:",
  41.         "Keep:",
  42.         "Treated:",
  43.         "Packed:"
  44. };
  45.  
  46.  
  47. void pascal node_lister (void) {
  48.  
  49.     static char zone[7]="";
  50.     static char net[7]="";
  51.     char lines;
  52.     struct nodeidx nid;
  53.     int returncode;
  54.     FIELD *fld;
  55.  
  56.     if(!nidxsize || !nidx) {
  57.         any_message(" No nodelist available. ");
  58.         pause();
  59.         return;
  60.     }
  61.     wnd6=establish_window(4,maxy-7,5,31);
  62.     set_border(wnd6,3);
  63.     set_title(wnd6," Nodelist Scanner ");
  64.     set_colors(wnd6,BORDER,7,0,0);
  65.     display_window(wnd6);
  66.     wcursor(wnd6,0,0);
  67.     wprintf(wnd6," F10 to list or ESC to abort");
  68.     if (!*zone || !(word)atol(zone)) {
  69.         sprintf(zone,"%u",curaddress.zone);
  70.         sprintf(net,"%u",curaddress.net);
  71.     }
  72.     init_template(wnd6);
  73.     wprompt(wnd6,1,1,"Zone:");
  74.     wprompt(wnd6,1,2,"Net:");
  75.     fld=establish_field(wnd6,7,1,msk5,zone,'N');
  76.     field_window(fld,"zone      ",40,6);
  77.     fld=establish_field(wnd6,7,2,msk5,net,'N');
  78.     field_window(fld,"net       ",40,5);
  79.     prep_template(wnd6);
  80. NodeOver:
  81.     returncode=data_entry(wnd6);
  82.     if (returncode==ESC){
  83.          delete_window(wnd6);
  84.          return;
  85.     }
  86.     if (returncode!=F10) goto NodeOver;
  87.     if (atol(zone)<1 || atol(zone)>65535L || atol(net)>65535L) {
  88.         error_message(" Invalid value(s)...zone=1-65535, net=0-65535 ");
  89.         pause();
  90.         goto NodeOver;
  91.     }
  92.     nid.zone=(word)atol(zone);
  93.     nid.net=(word)atol(net);
  94.     delete_window(wnd6);
  95.     nid.node=0;
  96.     nid.type=255;
  97.     wnd4=establish_window(0,0,maxy,maxx);
  98.     set_border(wnd4,1);
  99.     set_title(wnd4," NodeList ");
  100.     display_window(wnd4);
  101.     wcursor(wnd4,0,0);
  102.     any_message(" Searching ");
  103.     if (!nid.net) {
  104.         if (nodelist(&nid,3)==-1) goto BreakOut;
  105.         clear_message();
  106.         nid.type=3;
  107.         lines=2;
  108.         while(nodelist(&nid,4)>(-1)) {
  109.             lines+=2;
  110.             if (lines>=(maxy-3)) {
  111.                 any_message("More? (Y-n)");
  112.                 lines=toupper(generic_mouse_input(ewnd));
  113.                 clear_message();
  114.                 if (lines=='S' || lines=='N' || lines==ESC) goto BreakOut;
  115.                 lines=0;
  116.             }
  117.         }
  118.         any_message(" Complete ");
  119.         pause();
  120.         goto BreakOut;
  121.     }
  122.     clear_message();
  123.     if (nodelist(&nid,1)==-1) goto BreakOut;
  124.     nid.type=0;
  125.     lines=2;
  126.     while(nodelist(&nid,2)>(-1)) {
  127.         lines+=2;
  128.         if (lines>=(maxy-3)) {
  129.             any_message("More? (Y-n)");
  130.             lines=toupper(generic_mouse_input(ewnd));
  131.             clear_message();
  132.             if (lines=='S' || lines=='N' || lines==ESC) goto BreakOut;
  133.             lines=0;
  134.         }
  135.     }
  136.     any_message(" Complete ");
  137.     generic_mouse_input(ewnd);
  138. BreakOut:
  139.     clear_message();
  140.     delete_window(wnd4);
  141. }
  142.  
  143.  
  144.  
  145. int pascal nodelist (struct nodeidx *nii,char type) {
  146.  
  147.  struct nodeinfo nif;
  148.  char temp[91];
  149.  int handle;
  150.  long x;
  151.  static long cidx=0;
  152.  WINDOW *fake;
  153.  char len;
  154.  
  155.  if(!nidxsize || !nidx) {
  156.     any_message(" No nodelist available. ");
  157.     return (-1);
  158.  }
  159.  if (nii->zone==0) {
  160.     nii->zone=curaddress.zone;
  161.  }
  162.  
  163.  nif.zone=nii->zone;
  164.  nif.net=nii->net;
  165.  nif.node=nii->node;
  166.  nif.type=nii->type;
  167.  
  168.  if (type==2 || type==4) {
  169.     x=cidx;
  170.     if (type==2) goto GotwhatIwant;
  171.  }
  172.  else x=cidx=0;
  173.  if (type==3 || type==4) {
  174.      if (type==4) {
  175.         x++;
  176.         cidx=x;
  177.      }
  178.      for (;x<(nidxsize+1);x++) {
  179.         if (nidx[x].zone==nif.zone && nidx[x].node==0) break;
  180.      }
  181.      cidx=x;
  182.      goto GotwhatIwant;
  183.  }
  184.  for (;x<(nidxsize+1);x++) {
  185.     if (nidx[x].zone==nif.zone && nidx[x].net==nif.net && nidx[x].node==nif.node) break;
  186.  }
  187.  cidx=x;
  188.  
  189. GotwhatIwant:
  190.  
  191.  if (x>nidxsize) {
  192.      if (!type) {
  193.         wnd6=establish_window(3,maxy-5,4,maxx-6);
  194.         set_border(wnd6,3);
  195.         set_title(wnd6," Node Info ");
  196.         set_colors(wnd6,BORDER,7,0,0);
  197.         display_window(wnd6);
  198.         wcursor(wnd6,1,1);
  199.         wprintf(wnd6,"\t\t\t\tRequested Node not found. ");
  200.      }
  201.      return (-1);
  202.  }
  203.  if (type==2 || type==4) {
  204.     if (type==2) {
  205.         x++;
  206.         cidx=x;
  207.     }
  208.     if (x>nidxsize) return (-1);
  209.     if (type==2 && (nidx[x].zone!=nif.zone || nidx[x].net!=nif.net)) return (-1);
  210.     if (type==4 && (nidx[x].zone!=nif.zone || nidx[x].node!=0)) return (-1);
  211.  }
  212.  sprintf(temp,"%sQNL_DAT.BBS",nodepath);
  213.  if ((handle=_open(temp,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
  214.    error_message(" Can't open QNL_DAT.BBS ");
  215.    pause();
  216.    return(-1);
  217.  }
  218.  lseek(handle,x*(long)sizeof(struct nodeinfo),SEEK_SET);
  219.  if (_read(handle,&nif,sizeof(struct nodeinfo))<1) {
  220.     _close(handle);
  221.     goto ReadError;
  222.  }
  223.  _close(handle);
  224.  len=*nif.name;
  225.  memmove(nif.name,&nif.name[1],len);
  226.  nif.name[len]=0;
  227.  len=*nif.city;
  228.  memmove(nif.city,&nif.city[1],len);
  229.  nif.city[len]=0;
  230.  len=*nif.phone;
  231.  memmove(nif.phone,&nif.phone[1],len);
  232.  nif.phone[len]=0;
  233.  len=*nif.password;
  234.  memmove(nif.password,&nif.password[1],len);
  235.  nif.password[len]=0;
  236.  if (!type) {
  237.     wnd6=establish_window(3,maxy-5,5,maxx-6);
  238.     set_border(wnd6,3);
  239.     set_title(wnd6," Node Info ");
  240.     set_colors(wnd6,BORDER,7,0,0);
  241.     wcursor(wnd6,1,1);
  242.     fake=wnd6;
  243.     display_window(fake);
  244.  }
  245.  else fake=wnd4;
  246.  wprintf(fake,"\n");
  247.  wprintfraw(fake,"Type:%hd * %u:%u/%u (%s, %s)\n",nif.type,nif.zone,nif.net,nif.node,nif.name,nif.city);
  248.  wprintfraw(fake,"%s * %s * %u baud * %d cost * ",nif.phone,nif.password,nif.baud,nif.cost);
  249.  if (nif.flags & B_hub) wprintf(fake,"Hub  ");
  250.  if (nif.flags & B_host) wprintf(fake,"Host  ");
  251.  if (nif.flags & B_region) wprintf(fake,"RC  ");
  252.  if (nif.flags & B_zone) wprintf(fake,"ZC  ");
  253.  if (nif.flags & B_CM) wprintf(fake,"CM");
  254.  return(nif.cost);
  255.  
  256. ReadError:
  257.     error_message(" Error reading record ");
  258.     pause();
  259.     return (-1);
  260. }
  261.  
  262.  
  263.  
  264.  
  265. int dest_check (char *bf,int key) {
  266.  
  267.    struct nodeidx nid;
  268.  
  269.    if (!autocheck && *bf) return 0;
  270.    if ((currarea->attr & NET)==0 && (currarea->attr & ALTERNATE)==0) return 0;
  271.    nid.node=(word)atol(dest);
  272.    nid.net=(word)atol(dest_net);
  273.    nid.zone=(word)atol(d_zone);
  274.    clear_message();
  275.    nid.type=255;
  276.    sprintf(cost,"%-5d",nodelist(&nid,0));
  277.    if (*cost=='-') strcpy(cost,"0    ");
  278.    pause();
  279.    delete_window(wnd6);
  280.    if(wnd1)normal_video(wnd1);
  281.    if(wnd1)field_tally(wnd1);
  282.    if(wnd1)reverse_video(wnd1);
  283.    return 0;
  284. }
  285.  
  286.  
  287.  
  288. int orig_check (char *bf,int key) {
  289.  
  290.    struct nodeidx nid;
  291.  
  292.    if (!autocheck) return 0;
  293.    if ((currarea->attr & NET)==0 && (currarea->attr & ALTERNATE)==0) return 0;
  294.    nid.node=(word)atol(orig);
  295.    nid.net=(word)atol(orig_net);
  296.    nid.zone=(word)atol(o_zone);
  297.    clear_message();
  298.    nid.type=255;
  299.    nodelist(&nid,0);
  300.    pause();
  301.    delete_window(wnd6);
  302.    return 0;
  303. }
  304.  
  305.  
  306.  
  307. void find_sysop (char *bf) {
  308.  
  309.     int  fp;
  310.     char s[128];
  311.     char *p;
  312.     char first[36];
  313.     char last[36];
  314.     char searchname[39];
  315.     char changed=0;
  316.     int  x;
  317.     int  y;
  318.     long pos=0;
  319.  
  320.     strcpy(first,bf);
  321.     rstrip(first);
  322.     lstrip(first);
  323.     if (!strlen(first)) return;
  324.     strtok(first," ");
  325.     p=strtok(0," ");
  326.     if (p==NULL) *last=0;
  327.     else strcpy(last,p);
  328.     lstrip(last);
  329.     if (*last) sprintf(searchname,"%s, %s",last,first);
  330.     else strcpy(searchname,first);
  331.     pos=0;
  332.  
  333.     if (isalpha(*searchname)) {
  334.         sprintf(s,"%sFidoUser.IDX",nodepath);
  335.         if ((fp=_open(s,O_RDONLY | O_BINARY | O_DENYNONE))!=-1) {
  336.             lseek(fp,(long)((toupper(*searchname)-'A')*sizeof(long)),SEEK_SET);
  337.             _read(fp,&pos,sizeof(long));
  338.             _close(fp);
  339.         }
  340.     }
  341.     sprintf(s,"%sFidoUser.LST",nodepath);
  342.     if ((fp=_open(s,O_RDONLY | O_TEXT | O_DENYNONE))==-1) {
  343.         any_message(" No FidoUser.Lst available ");
  344.         pause();
  345.         return;
  346.     }
  347.     setmode(fp,O_TEXT);
  348.     lseek(fp,pos,SEEK_SET);
  349.     any_message(" Searching... ");
  350.     while (!eof(fp)) {
  351.         pos=tell(fp);
  352.         if (!fgetsx(s,128,fp)) break;
  353.         s[39]=0;
  354.         rstrip(s);
  355.         lstrip(s);
  356.         if (!stricmp(s,searchname)) {
  357.             lseek(fp,pos,SEEK_SET);
  358.             fgetsx(s,128,fp);
  359.             p=&s[41];
  360.             s[40]=0;
  361.             rstrip(s);